package com.bonshotels.DataLayer.CtrlDadesHibernate;

import org.hibernate.Session;
import org.hibernate.SessionFactory;

import com.bonshotels.DataLayer.Hibernate.HibernateUtil;

/**
 * Aquesta classe conte codi comu que fan servir els controladors de dades per accedir a Hibernate.
 * @autor Marc Mauri Alloza
 */
abstract class CtrlGeneralHibernate {
	
	/** The session factory. */
	private SessionFactory sessionFactory;
	
	/**
	 * Instantiates a new ctrl general hibernate.
	 */
	CtrlGeneralHibernate() {
		sessionFactory = HibernateUtil.getSessionFactory();
		sessionFactory.getCurrentSession().beginTransaction();
	}
	
	/**
	 * Gets the session.
	 *
	 * @return the session
	 */
	public Session getSession() {
		return sessionFactory.getCurrentSession();
	}

}
